ml-peak-shape-generator
Generate various peak shapes.
The current supported kinds of shapes:
Name | Equation |
---|
Gaussian | |
Lorentzian | |
Pseudo Voigt | |
where
Installation
$ npm i ml-peak-shape-generator
This package allows to calculate various shapes. By default they will have a height of 1.
You see the resulting functions using this playground
Usage
import {
getGaussianData,
getLorentzianData,
getPseudoVoigtData,
} from 'ml-peak-shape-generator';
let data = getGaussianData({ sd: 500 }, { factor: 3.5 });
let data = getGaussianData({ fwhm: 500 }, { factor: 3.5 });
let data = getLorentzianData({ fwhm: 500 }, { factor: 5 });
let data = getPseudoVoigtData({ fwhm: 500 }, { factor: 5 });
It is also possible to take an instance of each kind of shape:
import { Gaussian, gaussianFct, Gaussian2D } from 'ml-peak-shape-shape';
const gaussianShape = new Gaussian({ fwhm: 500 });
gaussianShape.fwhm = 300;
const gaussian2DShape = new Gaussian2D({ fwhm: 500 });
const gaussian2DShape = new Gaussian2D({ fwhm: { x: 300, y: 500 } });
gaussian2D.fwhm = { x: 300, y: 500 };
gaussian2D.fwhm = 400;
const gaussianShape = new Gaussian({ fwhm: 500 });
gaussianShape.fct(5);
gaussianFct(5, 500);
gaussianShape.getData({ factor: 3.5 });
import { getShape1D, getShape2D } from 'ml-peak-shape-generator';
let shapeGenerator = getShape1D({ kind: 'lorentzian', sd: 500 });
let shapeGenerator = getShape2D({ kind: 'gaussian', sd: 500 });
It is also possible to get a function that allows to calculate y for any x
import { gaussianFct } from 'ml-peak-shape-generator';
const func = gaussianFct(x - mean, fwhm);
License
MIT